;;;
;;; Kuty: system call wrapper
;;; 
BITS 64
;;; 
;;;  LICENSE AGREEMENT:
;;; 
;;;  You agree that we don't agree to anything.
;;; 
;;; 
;;;  DISCLAIMER OF WARRANTIES:
;;; 
;;;  This software is provided to you "AS IS," and the authors and
;;;  contributors disclaim any warranty or liability obligations to you
;;;  of any kind, implied or express, including but not limited to the
;;;  warranties of merchantability, fitness for a particular purpose,
;;;  and non-infringement.
;;; 
section .data align=16
errno dq 0
;;; 
section .text align=16
%assign ELAST 92
global shmget_, shmat_, shmdt_, shmctl_
global fork_,wait4_,kill_
global write_
global geterrnoa_
global stat_
global faccess_
;;; 
%assign rc 0x04
;;; 
%macro return 0
	mov qword [errno], rax
	or rax, rax
	jz %%.exit
	cmp rax, ELAST	
	jbe %%.failure
%%.exit:
	pop rbp
	ret
%%.failure:
	mov [errno], rax
	mov rax, -1
	jmp %%.exit
%endmacro
;;;
%macro dosyscall 1
	push rbp
	mov rbp, rsp
	;;
	mov rax, %1
	syscall
	return
%endmacro
;;;
shmget_: dosyscall 231
shmat_: dosyscall 228
shmdt_: dosyscall 230
shmctl_: dosyscall 229
fork_:	dosyscall 2
wait4_: dosyscall 7
kill_:	dosyscall 37
write_: dosyscall 4
open_:	dosyscall 5
close_:	dosyscall 6
lseek_:	dosyscall 19
stat_:	dosyscall 278
faccess_: dosyscall 33
;;; 
geterrnoa_:
	push rbp
	mov rbp, rsp
	mov rax, [errno]
	pop rbp
	ret

